const jwt = require(jsonwebtoken);
//检查是否有token
module.exports = async (ctx,next) => {
    const authorization = ctx.get('Authorization') || '';
    if(authorization) {
        try {
            ////如果token过期或验证失败，将抛出错误
            let tokenContent = await jwt.verify(authorization,'tokenxxx');
            console.log(tokenContent);
            ctx.userInfo = tokenContent || {}
            
        } catch (err) {
            ctx.body = {
                code: 500,
                massage: err,
                data: []
            }
        }
    }
}